package com.food.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.food.model.Course;
import com.food.dao.service.CourseService;

/**
 * Servlet implementation class DisplayCourse
 */

/*胖達*/

@WebServlet("/course/OneCourse")
public class OneCourse extends HttpServlet {
	private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public OneCourse() {
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}
	
	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		CourseService service = new CourseService();
		int cid = Integer.parseInt(request.getParameter("cid"));
		Course course = new Course();
		course.setCid(cid);
		Course coll = service.findOneCourse(course);
		request.setAttribute("course", coll);
		RequestDispatcher rd = request
				.getRequestDispatcher("/course/cintroduce.jsp");
		rd.forward(request, response);
		return;
		
	}

}
